package com.bw.demo;

import javax.validation.Validation;
import javax.validation.Validator;

import org.hibernate.validator.HibernateValidator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class SpringValidationDemoApplication {
	
	/**
	 * 注解快速失败使用
	 * @return
	 */
	@Bean
	public Validator validator() 
	{
		// failFast是否开启快速失败
		return Validation.byProvider(HibernateValidator.class).configure()
				.failFast(false).buildValidatorFactory().getValidator();
	}

	public static void main(String[] args) {
		SpringApplication.run(SpringValidationDemoApplication.class, args);
	}

}
